//
//  AdViewController.m
//  WidgetDemo
//
//  Created by 航汇聚科技 on 2017/12/21.
//  Copyright © 2017年 Yi Zhou. All rights reserved.
//


#import "AdViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+LoadGifImage.h"

@interface AdViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *adImageView;
@property (weak, nonatomic) IBOutlet UIButton *adBtn;

@end

static NSString *adGifPath = @"https://mmbiz.qpic.cn/mmbiz_gif/iblMQCBsLDQGu3OjgCf0yicthh7UrSoia4Uoibj6Sg5vEibOJsSpWUn0WUkQMkRW8FScsRgc0aKmIW6ib1Np1wlqHclw/0?wx_fmt=gif";

@implementation AdViewController

- (void)awakeFromNib {
    [super awakeFromNib];
}

static int totalTime = 3;
- (void)colseLaunchScreen {
    totalTime--;
    [self.adBtn setTitle:[NSString stringWithFormat:@"跳过%ds",totalTime] forState:UIControlStateNormal];
    if (totalTime <= 0 && self.parentViewController) {
        [self removeFromParentViewController];
        [self.view removeFromSuperview];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    [self.adImageView yh_setImage:[NSURL URLWithString:adGifPath]];
    [self.adBtn setTitle:[NSString stringWithFormat:@"跳过%ds",totalTime] forState:UIControlStateNormal];
    //设置3秒定时触发
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(colseLaunchScreen) userInfo:nil repeats:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
